<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/commons/page/codegen.jsp"%>
	
   
   <%--  <link href="${ctx}/js/gpoint/rdp/zone/css/bootstrap.min.css" rel="stylesheet" />  --%><!-- 不注释掉这个找不到箭头 -->
     <link href="${ctx}/js/gpoint/rdp/zone/css/bootstrap-duallistbox.min.css" rel="stylesheet" /> 
    
   <%-- <script src="${ctx}/js/gpoint/rdp/zone/jquery-3.0.0.min.js"></script> --%><!--  这个必须去掉，第一个界面调用不起来 -->
    <script src="${ctx}/js/gpoint/rdp/zone/bootstrap.min.js"></script>  
    <script src="${ctx}/js/gpoint/rdp/zone/jquery.bootstrap-duallistbox.js"></script>
    <link type="text/css" rel="stylesheet" href="${ctx}/js/gpoint/rdp/zone/css/bootstrap.css">





<style type="text/css">

#mermbers {
	width: 98%;
    margin: auto;
    margin-top:15px;
}

.myButton{
    BORDER: 1PX SOLID;
    PADDING: 2PX;
    BACKGROUND-COLOR: #337ab7;
    COLOR: WHITE;
    BORDER-RADIUS: 5PX;
    height: 27px;
}

.myLink{
    BORDER: 1PX SOLID;
    PADDING: 5PX;
    BACKGROUND-COLOR: #337ab7;
    COLOR: WHITE;
    BORDER-RADIUS: 5PX;
}
</style>


</head>
<body>

<div class="panel panel-default">
    <div class="panel-heading">
      <!--   不带 title 的面板标题 --> 权限类型选择
    </div>
    <div class="panel-body">
     <!--    面板内容 -->
	 <div class="toolbar-body" >
	      
						<form role="form" class="search-form">
						  
							<div  class="form-inline p-xxs">	
							    
						<form role="form" class="search-form">
						  
							<div  class="form-inline p-xxs">	
							    <div class="form-group">
										   请选择 时间段<select id="datasetProperty" onchange="cge()">  </select>
								</div>
														
								<div class="form-group">
										<label class="search-label" >开始日期 </label>:	<input reayonly="reayonly" type="text" name="s1"  id="s1"   />
								</div>
								<div class="form-group">
									<label class="search-label" >结束日期 </label>:	<input  reayonly="reayonly" type="text" name="s2"  id="s2" />
								</div>	
								
								<div class="form-group">
										 <a id="showValue3" class="btn btn-primary fa fa-search" href="javascript:void(0);" ><span>允许</span></a>
								</div>		
								
								<!-- <div class="form-group">
										 <a id="showValue4" class="btn btn-primary fa fa-search" href="javascript:void(0);" ><span>明细</span></a>
								</div>	 -->
								
														
								
																
							</div>
						</form>
					</div><!--/ 查询条件-->
    </div>
</div>
 
    <ul id="myTab" class="nav nav-tabs">
		<li class="active">
		   <a href="#home" data-toggle="tab">用戶</a>
		</li>
	    <li><a href="#ios" data-toggle="tab">门列表</a></li>

	</ul>
	
	
	<div id="myTabContent" class="tab-content">
	
		<div class="tab-pane fade in active" id="home">
			<div class="wrapper wrapper-content  animated fadeInRight col-sm-12">    	
					<div class="jqGrid_wrapper" id="mermbers" >		
						<div>
						   <label class="fr-control-label"></label>
							<div class="fr-form-group">
								<input class="myButton" type = "button" value = "选择名单"  onclick="selectMember();">
		
								<a class="myLink" href="javascript:void(0);" onClick="downloadExcel();">模板下载</a>
								<a class="myLink" href="javascript:void(0);" onClick="fileClick()">批量导入</a>
								<input type="file" id="upfile" name="upfile" placeholder="" οnchange="importExp();" style="display: none;"/>
						
							</div>
						</div>	
						<table id="campusCardGrid" ></table>
						<div id="campusCardPager"></div>
					</div>
			</div>
	


		</div>
	
		<div class="tab-pane fade in" id="ios">
		    <!--  门列表开始 -->
	  	        <div class="panel panel-default" >
					    <div class="panel-heading">
					         门选择
					    </div>
								<div class="panel-body" style="height:600px;" >
											 <div class="col-md-12"  >
											 
																	
																	<div class="panel panel-default">
									  
																			<div class="panel-body">
																												
																												 <div class="toolbar-body" >
																													  
																																	
																																		
																																			<div  class="form-inline p-xxs">	
																																				<div class="form-group">
																																						<label>区域</label>
																																				</div>
																																										
																																				 
																																			 <div class="form-group">
																																						  <input name="m:doorController:zoneid" type="hidden"   id="hid_zoonid" value="${zoneid}"/>						    					
																																					<input type="text" data-key="#hid_zoonid" readonly="readonly"  class="form-control comboTree" data-toggle="dictionary" data-url="${ctx}/rdp/area/zone/list_json_tree_zone.htm?ids=${zoneid}" value="${zonename}"  validate="{required:true}"/>
																																				</div> 
																																				      <!-- <div class="form-group">
																																		<select id="zoneevent" onchange="zoneevent();">  </select>
																																                     </div> -->
											
																																				<div class="form-group">
																																						<label>控制器</label>
																																				</div>		
																																				<div class="form-group">
																																												<input type="text" id="ctl">
																																												
																		 																							
																																				</div>	
																																				<div class="form-group">
																																						<label>门名称</label>
																																				</div>		
																																				<div class="form-group">
																																												<input type="text" id="doorname">
																																												  <button  onclick="queryctl()" > 查询 </button>
																																											
																																				</div>								
																																			</div>
																																	
																													  
																																			
																													  
																													  
																																</div><!--/ 查询条件-->
																			</div>
																</div>
															
															<select multiple="multiple" size="10" name="duallistbox_demo2" class="demo2" style="height: 200px;">
															</select>
							  
															 <ul  class="pagination"  id="page"></ul>
														</div>
											</div> 
						            
						            
						               
						                    
						                    
						                    
				</div>
	  
								 
  
  
    
	        <!--  门列表结束 -->
    </div>
</div>
 
 
								
								     
													
													
													
											    
											       
											    </div>
						            </div> 
						            
						            
						               
						                    
						                    
						                    
				</div>

        </div>
    </div>
						            
						            
						               
						                    
						                    
						                    
				</div>

        </div>
   <!--  </div> -->
	         
		<!-- </div> -->
 <!--    </div> -->

    <script type="text/javascript">
	   var meettingid='${meetingManage.id}'; 	   
	   var ids = [];
	   var win = {};
	   //通过指定的ID重加载表格
	   function refreshGrid(ids){		   
		   $("#campusCardGrid").jqGrid('clearGridData');  //清空表格
		   $("#campusCardGrid").jqGrid('setGridParam',{
			    url:'${ctx}/rdp/user/campusCard/listByIds.htm?ids='+ids.toString()
		   }).trigger("reloadGrid");	
		   $("#members").attr("value",ids.toString());
		   console.log(ids);
		   
	   }
	   //人员选择
	   var selectMember = function (){
		  var iwidth = 1300;
		  var iheight = 600;
		  var itop = (window.screen.availHeight-iheight)/2;       //获得窗口的垂直位置;
		  var ileft = (window.screen.availWidth-iwidth)/2;      //获得窗口的水平位置; 		   		   
		  win = window.open(
				"${ctx}/rdp/popup/tree.htm", 
				"人員選擇", 
				"status=no,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,top="+itop+",left="+ileft+",width="+iwidth+",height="+iheight
		   );   
	   }
	   //彈窗回調
	   var initIds = function (addIds){
		   //合并
		   ids = ids.concat(addIds);
		   //去重
		   ids = ids.filter((item, index, self) => self.indexOf(item) ==index);		   
		   win.close();
		   refreshGrid(ids);
	   }
	   //移除
       function removeGridData(id){
    	   for (var i = 0; i < ids.length; i++) { 
    		   if (ids[i] == id) {
    			   ids.splice(i, 1); 
    			   break;
    		   }    		
    	   }
    	   refreshGrid(ids);
       }
	   //模板下載
       function downloadExcel() {    	    
      	    window.location.href="${ctx}/rdp/popup/downloadExcel.htm";
       }
       //上传
       function fileClick(){
      	  $("#upfile").click();
       }
       
	   //初始化表单
       $(function(){
    	   gridInit();
    	   //绑定上传事件
    	   $("#upfile").change(importExp);
       });
       //上传事件
       function importExp() {
    		//var index = layer.load(1, {time: 20*1000});  // 调用加载层
    		var formData = new FormData();
    		var name = $("#upfile").val();
    		formData.append("name",name);
    		formData.append("file",$("#upfile")[0].files[0]);
    	 
    		$.ajax({
    			url : '${ctx}/rdp/popup/uploadExcel.htm',
    			type : 'POST',
    			data : formData,
    			//ajax2.0可以不用设置请求头，但是jq帮我们自动设置了，这样的话需要我们自己取消掉
    			contentType:false,
    			//取消帮我们格式化数据，是什么就是什么
    			processData:false,
    			success : function(data) {
    				//关闭 加载层
    				//layer.close(index);
    				if(data.status==true){
    				//layer.msg("导入成功");
    				   var newAddIds = data.ids;
    				   ids = ids.concat(newAddIds);
    				   ids = ids.filter((item, index, self) => self.indexOf(item) ==index);	
    				   
    				   refreshGrid(ids);    				 
    				}else{
    				//layer.msg("导入失败");
    				}
    		    }
    		});
    	 
    		$("#upfile").val("");
    	}
       
                   
       function gridInit(){
    	   $("#campusCardGrid").GridList(
					{
						url :  '${ctx}/rdp/user/campusCard/permissionUserList.htm?meetingId=',
						pager :"#campusCardPager",
						colNames: ['ID','工号','姓名','卡UID','电话','部门代码','部门名称','性别','操作'],
				        colModel: [{
		                 	   name:'id',
		                	   index: 'ID',
		                	   hidden:true		                	  
		                	},	
		                	 {                  		 
			                 	   name:'usernum',
			                	   index: 'USERNUM',   
			                	   
			                	   key:true
			                	},
		                	{
		                 	   name:'username',
		                	   index: 'USERNAME'
		                	},
                           	
                            {
		                 	   name:'carduid',
		                	   index: 'CARDUID'
			                },	
		                	{
		                 	   name:'phone',
		                	   index: 'PHONE'
		                	 },  
		                	 {
		                 	   name:'orgcode',
		                	   index: 'ORGCODE',
		                	   hidden:true,
                             },   
		                	 {
			                 	   name:'orgname',
			                 	   index: 'ORGNAME',
			                	   sortable: false 
                             }, 
                             {
		                 	   name:'sex',
		                	   index: 'SEX',
		                	   formatter:function(cellValue, options, rowObject){
		                		   if(cellValue==1){
		                			   return '男';
		                		   }else{
		                			   return '女';
		                		   }
		                	   }
                             }, 
                             {
									name : '__manage',
									width : 30,
									sortable:false,
									formatter:function(cellValue, options, rowObject){
										var id = options['rowId'];
										var html = '<a  href="javascript:void(0);" onclick = "removeGridData(\''+id+'\');">删除<a>'
										return html;

				                	}
		                	 
		                	        
							} ],

							//点击行，进行单选
					        //要求：editable:false
					        onSelectRow: function (rowId, status, e) {
					        	
					            var ids=$('#campusCardGrid').jqGrid('getGridParam','selarrrow');
								selectIds = ids;

					        },
							//点击题头的checkbox按钮，一键多选
					        onSelectAll:function(rowids,statue){
					            selectIds = rowids;
					        }						
	
					});
       }


	</script>



<script type="text/javascript">





function appendHtml2(returnData) {//此函数用于处理后台返回的数据，根据自己需求来实现页面拼接
	  var objs = $.parseJSON( JSON.stringify(returnData));
	 // alert("aaa");

	  if(objs==null ){
		  alert("门数据获取异常！");
		   return;
		  
	  }else{
		  $(objs).each(function () {
		       
		         var objA=objs.rows;    
		         
		         var json = [];
               
               $(objA).each(function () {
            	   var o = document.createElement("option");
                   
                   
                   var label = this['key'];
	                
	                console.log(label);
	                
	                
                  var value = this['doorno']+","+this['doorname'];
              
                  var  flag=this['selectedflag'];
                 
                  if(!flag){ //flase 
                  
                   $('.demo2').append('<option value="' + value + '">' + label + '</option>');
                  }else{
               	   $('.demo2').append('<option value="' + value +'" selected="selected">' +label + '</option>');
                  }
                  
               });
               
              
	            
		       
		         $('.demo2').bootstrapDualListbox('refresh');
		       
		    });      //渲染dualListbox
		    $('.' + 'demo2' + '').bootstrapDualListbox({
		    	  nonSelectedListLabel: '门列表',
		          selectedListLabel: '已选择门数：',
		          preserveSelectionOnMove: 'moved',
		          moveOnSelect: false//,
		    });
	  }
 
  
}




	
	
var doornum=0;
function a(caruid){
	  var strs = new Array(); //定义一数组
	  
	   strs =  String(caruid).split(","); //字符分割

	   doornum=strs.length/2;
	//   alert("获取门的总数集合"+doornum);
	   
	   var b=[];
	   for (i=0; i<strs.length; i++ ){
	        
		   if(i%2==0){  
			   if(i==0){
				  
				   b.push(String (strs[i])+","+strs[i+1]+"|");
			   }else{
				 
				  
				   b.push(String (strs[i])+","+strs[i+1]+"|");
			   }
			   
		   }
	   }
	   console.log(b);
	   return b;
	  //end
}



	
	var selectvalue;

/* 
	var index; //时间框控件选择数值
	var selectvalue; */
$("#showValue3").click(function () {
	//alert("授权进行");
	//得到第一个列表
       
	
	   
	//  alert(b);
	//得到门列表
	  var doorlist=$('[name="duallistbox_demo2"]').val(); 
	  
	  //alert("doorlist="+doorlist);
	   c= a(doorlist);
	 // alert(c);
	  

	//  alert(selectvalue);
	
	  
	  //得到下拉框的数值
	 var permissonselect=$("#permissionProperty").val();    
	  
	  
	//1.判断为空，必须填完才能进行保存，不能进行类型授权操作：
		if(doorlist!=null  && doorlist.length!=0  && ids!=null && ids.length!=0 ){

			 //拼成JSON数组传递
			   var str = [];
				    		 
				    		  // var doorArr = ["111","222"]; //控制器SN号，门号
				    		   var doorArr = c; //控制器SN号，门号
				    		   
				   //3.用户权限
				    		  var map ={};
				    		
		    		    	   map.startTime=  $("#s1").val( );
		    		    	     map.doorArr = doorArr; //门列表 和时间段
		    		    	     map.endTime=    $("#s2").val(); 
		    		    	   //  alert(ids);
		    		    	     map.useArr=ids;
		    		    	     map.str=selectvalue;
		    		    	   
		    				  
		    		    	     
		    		    	     
		    		    	     
		    		    	         	 
		    	//4.存入doorpremisson
		    	    
				    	     $.ajax({
  		    	         	type: "post",
  		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/query",
  		    	         	    contentType: "application/json;charset=utf-8;",
  		    	         	  data:JSON.stringify(map),
  		    	         	  dataType:"json",//注意不是datatype哦
  		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
  		    	         	   success: function(data) {
  		    	         		  console.log(data);
  		    	         	       //  alert("查询用户信息成功！");
  		    	         	 
  		    	         	 
  		    	         	if(data.result==0){ //不存在

	    		    	           $.ajax({
	    		    	         	type: "post",
	    		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/save3",
	    		    	         	    contentType: "application/json;charset=utf-8;",
	    		    	         	  data:JSON.stringify(map),
	    		    	         	  dataType:"json",//注意不是datatype哦
	    		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
	    		    	         	   success: function(data) {
	    		    	         	          alert("用户卡绑定成功！");
	    		    	         	  },
	    		    	         	 error: function(){
	    		    	         		  alert("用户卡绑定失败！");
	    		    	              }
	    		    	         	 
	    		    	         	 }); 
	    		    	         	 //end
		    	         	   }else		   if(data.result==1){//存在
		    	         		  //提示信息
		    	         	        DialogUtil.confirm(data.message + ',是否继续操作',
										function(rtn) {
										if(rtn){
											window.location.reload(true);
													   //更新入库
													     $.ajax({
				    		    	         	type: "post",
				    		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/update",
				    		    	         	    contentType: "application/json;charset=utf-8;",
				    		    	         	  data:JSON.stringify(map),
				    		    	         	  dataType:"json",//注意不是datatype哦
				    		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
				    		    	         	   success: function(data) {
				    		    	         	          alert("用户卡绑定成功！");
				    		    	         	  },
				    		    	         	 error: function(){
				    		    	         		  alert("用户卡绑定失败！");
				    		    	              }
				    		    	         	 
				    		    	         	 }); 
													     //end
										}   
										else{
											
										}
									    	
										});
		    	         	   }else{
		    	         		   
		    	         	   }
	    		    	         	 
	    		    	         	       
	    		    	         	        
	    		    	         	        
	    		    	         	  },
	    		    	         	 error: function(){
	    		    	         		  alert("查询门信息失败！");
	    		    	              }
	    		    	         	 
	    		    	         	 }); 
	    		    	         	 //end
	    		    	         	 
		    	 /* $.ajax({
		    		    	         	type: "post",
		    		    	         	   url: _ctx+"/rdp/doorPermission/doorPermissonType/save3",
		    		    	         	    contentType: "application/json;charset=utf-8;",
		    		    	         	  data:JSON.stringify(map),
		    		    	         	  dataType:"json",//注意不是datatype哦
		    		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
		    		    	         	   success: function(data) {
		    		    	         	          alert("绑定门权限类型成功！");
		    		    	         	  },
		    		    	         	 error: function(){
		    		    	         		  alert("绑定门权限类型失败！");
		    		    	              }
		    		    	         	 
		    		    	         	 }); 
		    		    	         	 //end */
		    		    	         	 
		    		    
		    		    	         	 
		    		    	         	 
		    		    	         	 
		    		    	         	 
		    		    	         	 
		    		    	         	 
		    		    	         	 
		    	
	    	         	 
			
			
		}else{
			alert("必须填完才能进行保存，不能进行类型授权操作");
		}
	  
	  
     
});





//下拉栏表框初始化初始化      
//初始化赋值
$(function () {
    //初始化时间段控件
    initList('hangwei.cnblogs.com', 'demo1');
    initdate(0);
  //  initzonelist();
 
});


function initList(queryParam1,selectClass, selectedDataStr) {
	//alert("时间段初始化");
    var paramData = {
        'testParam1': queryParam1
    }
    $.ajax({
        url: _ctx+"/rdp/TimeSegment/timeSeg/getData",
        type: 'get',
        data: paramData,
        async: false,
        success: function (returnData) {
        	console.log(returnData);
            var objs = $.parseJSON( JSON.stringify(returnData));
      
           
          var html = "";
           $('#datasetProperty').append("<option value='0'  checked='checked'>--任意时间有效--</option>");
            for (var i in objs) {
            	html += '<option value=' + objs[i].timeseg  + '>' + objs[i].timeseg + '</option>'
            }
            $("#datasetProperty").append(html); //渲染
        },
        error: function (e) {
            alert(e.msg);
        }
    });
}
//下拉栏表框初始化完毕    


//区域选择下拉框开始
function  initzonelist(){
	   
	//得到数值
	//var objs=${namelist}; //EL  表达式获取
	
	console.log(objs);
	var html;
	  $('#zoneevent').append("<option value='0'  checked='checked'>--任意时间有效--</option>");
	  
	  for (var i in objs) {
            	html += '<option value=' + objs[i].zoneid  + '>' + objs[i].zonename + '</option>'
            }
         $("#zoneevent").append(html); //渲染
	
	
}
//区域选择下拉框结束


//区域选择事件 
 
	function zoneevent(){
	alert("zoneevent 执行");
	    var sel=document.getElementById('zoneevent');
	        var sid=sel.selectedIndex;
	  //  alert(sel[sid].value+'-'+sel[sid].innerHTML);
	     index=sel[sid].innerHTML;
	    alert("zone index="+index);
	    selectvalue=sel[sid].value;
	  
	   alert("zone 获取选择数值="+selectvalue);
	     
	} 
	  




               var   id=$("#permissionProperty").val();
         
    //第二个列表框初始化      
        //初始化赋值
      $(function () {
            //初始化
            initListBox2('hangwei.cnblogs.com', 'demo2');

            $("#showValue2").click(function () {
                alert($('[name="duallistbox_demo2"]').val());
            });
        });
        /*初始化duallistbox*/
        //queryParam1：参数
        //selectClass：select元素class属性
        //selectedDataStr：选中数据，多个以,隔开
        function initListBox2(queryParam1,selectClass, selectedDataStr) {
            var paramData = {
                'testParam1': queryParam1
            }
            $.ajax({
                url: _ctx+"/rdp/door/door/getData2?ids=${zoneid}",
                type: 'get',
                data: paramData,
                async: true,
                success: function (returnData) {
                    var objs = $.parseJSON( JSON.stringify(returnData));
                 //   alert("aaaa");
                  // console.log(objs);
                  
                    var json = [];
                    
                    $(objs).each(function () {
                    	  var o = document.createElement("option");
                          
                          
                          var label = this['key'];
      	                
      	                console.log(label);
      	                
      	                
                         var value = this['doorno']+","+this['doorname'];
                     
                         var  flag=this['selectedflag'];
                        
                         if(!flag){ //flase 
                         
                          $('.demo2').append('<option value="' + value + '">' + label + '</option>');
                         }else{
                      	   $('.demo2').append('<option value="' + value +'" selected="selected">' +label + '</option>');
                         }
                    });
                    
               
    	            
                    //渲染dualListbox
                    $('.' + selectClass + '').bootstrapDualListbox({
                        nonSelectedListLabel: '门列表 ',
                        selectedListLabel: ' 已选择门数：',
                        preserveSelectionOnMove: 'moved',
                        moveOnSelect: false//,
                        //nonSelectedFilter: 'ion ([7-9]|[1][0-2])'
                    });
                },
                error: function (e) {
                    alert(e.msg);
                }
            });
        } 
//第二个列表框初始化完毕
      

  function cge(){
    var sel=document.getElementById('datasetProperty');
            var sid=sel.selectedIndex;
  //  alert(sel[sid].value+'-'+sel[sid].innerHTML);
     index=sel[sid].innerHTML;
  //  alert("index="+index);
    selectvalue=sel[sid].value;
     
     
     //  alert("获取选择数值="+selectvalue);
}      


 
  
 ////列表框事件：
	   
  
  
  
  
 
	 function getCurDate(){

		   var myDate = new Date();

		    //获取当前年
		   var year = myDate.getFullYear();

		   //获取当前月
		   var month = myDate.getMonth() + 1;

		    //获取当前日
		    var date = myDate.getDate();
		    var h = myDate.getHours(); //获取当前小时数(0-23)
		    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
		    var s = myDate.getSeconds();

		   //获取当前时间

		   //var now = year + '-' + conver(month) + "-" + conver(date) ;
		   var now = year + '' + conver(month) + "" + conver(date) ;
		   return now;

		}  
	 
	  
	  
	  //查询控制器
	  function   queryctl(){  
		     
		//  (" 查询控制器信息,请稍等...");
	   
	     //获取信息
	       var ctl= $("#ctl").val();
	       var zoneid= $("#hid_zoonid").val();
	       
	       var doorname= $("#doorname").val();
	     //发送ajax请求
	       $.ajax({
        url: _ctx+"/rdp/door/door/query",
        type: 'get',
        data : {ctl : ctl,zoneid:zoneid,doorname:doorname}, //参数：当前页为1
        async: false,
        success: function (data) {
        	       console.log(data);
        	      
        	       $("." + 'demo2' + "").empty();
					  
					   $('.demo2').bootstrapDualListbox('removeSelectedLabel');
					
					   $('.demo2').bootstrapDualListbox('setMoveAllLabel','', true);
					   
					   appendHtml2(data);
        	      
        },
        error: function (e) {
            (e.msg);
        }
    });
	     //结果赋值
		      }  
	  
	  
	
	  
	  
	 
		
		

	function getDate(){

		   var myDate = new Date();

		    //获取当前年
		   var year = myDate.getFullYear();

		   //获取当前月
		   var month = myDate.getMonth() + 1;

		    //获取当前日
		    var date = myDate.getDate();
		    var h = myDate.getHours(); //获取当前小时数(0-23)
		    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
		    var s = myDate.getSeconds();

		   //获取当前时间

		   var now = year + '-' + conver(month) + "-" + conver(date) + " " + conver(h) + ':' + conver(m) + ":" + conver(s);

		}

		//日期时间处理
		function conver(s) {
		return s < 10 ? '0' + s : s;
		}
		
		
		
		
		function appendHtml3(returnData) {//此函数用于处理后台返回的数据，根据自己需求来实现页面拼接
			  var objs = $.parseJSON( JSON.stringify(returnData));

		  $(objs).each(function () {
		     
		       var objA=objs.rows;    
		       for(var i=0;i<objA.length;i++){
		    	   var s1=objA[i]['startdate'];
		    	   var s2=objA[i]['enddata'];
		    	    $("#s1").val( getMyDate(s1));//jquery通过id属性并修改value属性为123
		    	    $("#s2").val(getMyDate(s2)); 
		          
		       }
		     
		      
		     
		  });     
		 
		  
		}

		//时间控件初始化完毕

	 
  function getMyDate(str){  
	        var date = new Date(str),  
	        oYear = date.getFullYear(), //年  
	        oMonth = date.getMonth()+1, //月  
	        oDay = date.getDate(),  //日
	        h = date.getHours(),//小时
	        m = date.getMinutes(),//分钟
	        s = date.getSeconds();//秒数
	        // 以自己需要的方式拼接
	   //     var oTime = oYear +'-'+ getZero(oMonth) +'-' + getZero(oDay)+' ' + getZero(h) + ':' +  getZero(m)+ ':' +  getZero(s);//最后拼接时间  
	       var oTime = oYear +''+ getZero(oMonth) +'' + getZero(oDay);     
	         return oTime;  
	      }

  function   getZero(num){  
	        // 单数前面加0
	        if(parseInt(num) < 10){  
	          num = '0'+num;  
	        }  
	        return num;  
	      }
  
  
	
function getendDate(){

	   var myDate = new Date();

	    //获取当前年
	   var year = myDate.getFullYear()+10;

	   //获取当前月
	   var month = myDate.getMonth() + 1;

	    //获取当前日
	    var date = myDate.getDate();
	    var h = myDate.getHours(); //获取当前小时数(0-23)
	    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
	    var s = myDate.getSeconds();

	   //获取当前时间

	   //var now = year + '-' + conver(month) + "-" + conver(date) ;
	   var now = year + '' + conver(month) + "" + conver(date) ;
	   return now;

	}
	
		
		
	  function initdate(ctl) {
			 // alert(" 查询时间段,请稍等...");
			   
			 if(ctl==0){
				 //  alert("查询时间段默认为当前时间");
				 startDate=getCurDate();
			          endDate=getendDate();
				   $("#s1").val( startDate);//jquery通过id属性并修改value属性为123
			      $("#s2").val(endDate); 
			 }else{
						//获取信息
					      // var ctl= 1;
					     //发送ajax请求
					$.ajax({
				    url: __ctx+"/rdp/TimeSegment/timeSeg/querytime",
				    type: 'get',
				    data : {ctl : ctl}, //参数：当前页为1
				    async: false,
				    success: function (data) {
				    	       console.log(data);
				    	      appendHtml3(data);
				    	      
				    },
				    error: function (e) {
				        alert(e.msg);
				    }
		});
				 
			 }
		}	
	  
	  
	  
	  var index;
	  function cge(){
	    var sel=document.getElementById('datasetProperty');
	            var sid=sel.selectedIndex;
	  //  alert(sel[sid].value+'-'+sel[sid].innerHTML);
	     index=sel[sid].innerHTML;
	  //  alert("index="+index);
	    selectvalue=sel[sid].value;
	  
	   //alert("获取选择数值="+selectvalue);
	      initdate(selectvalue);
	} 
	  
	  
	//alert 执行
		$("#showValue4").click(function () {
			//alert("查询时间段明细");
			
			//得到当前选择数值
			  curselectedindex=selectvalue;
			
			//alert("curselectedindex="+curselectedindex);
			//弹框 赋初值
			 //弹框
				    DialogUtil.dialog(
						 {
				 				title : "时间段明细查询",
				 				content : __ctx+'/rdp/zone/doorZone/timeSegDetail?id='+curselectedindex,
				 				area : [ '1000px', '820px' ],
				 				maxmin : false,
				 				end : function() {
									
								}
				 			
				 		}
				 ); 
			
			//显示diaglog
			
			
			
			
		});
    </script>










	<!-- 顶部按钮 -->
	
	
</body>
</html>